<template>
    <div>
        <br />
        <myheader/>

        <div class="container">

          <div class="item_column">
              <div class="left">   
                  
              </div>

              <div class="right"> 
                  
                  <br />
                  <br />

                  <div>
                    <P v-for="i in paramslist" :key="i.id">
                        <van-field v-if="i.type == 'input'" :label="i.lable" type="datetime" v-model="values[i.lable]"/>
                        <select v-if="i.type == 'select'"  v-model="values[i.lable]">
                            <option :value="o.type" v-for="o in i.values" :key="o.id">{{o.name}}</option>
                        </select>
                        <van-uploader v-if="i.type == 'file'"/>
                        <el-date-picker v-if="i.type == 'datetime'"
                            v-model="value1"
                            type="datetimerange"
                            range-separator="To"
                            start-placeholder="开始时间"
                            end-placeholder="结束时间"
                            >
                        </el-date-picker>
                    </P>
                    <van-button @click="submit">提交</van-button>
                </div>
              </div>
            </div>
        </div>
    </div>
</template>

<script>
import myheader from './myheader.vue'
import maxios from '../http/axios'

export default{

    components: {
        'myheader':myheader,
    },

    data () {
        return {
            wid:this.$route.query.id,
            workf:{},
            paramslist:[],
            value1:[],
            values:{},
            pic:'../assets/微信图片_20211215111401.png',

            
        }
    },

    methods: {
        // 获取工作流
        getwork(){

            maxios('/getworkf','get',{'id':this.wid}).then(res => {

                this.workf = res.workf
                
                this.paramslist = JSON.parse(res.workf.params) 
            })
        },

        getlabelByType(type){
            let label = ''

            for(var i=0;i<this.paramslist.length;i++){

                if(this.paramslist[i]['type'] == type){

                    label = this.parselist[i]['lable']
                }
            }

            return label

        },
        submit(){

            // console.log(this.values)
            // console.log(this.value1)

            if(this.pic){
                let label = this.getlabelByType('file')
                this.values['label'] = this.pic

            }
            if(this.value1.length>0){
                let stime = this.getlabelByType('datetime')

                this.values[stime] = this.value1[0]
                this.values['结束时间'] = this.value1[1]
                 
            }
            
            console.log(this.values)


        },

    },

    mounted () {
        this.getwork()
    
    }
}
</script>

<style>

</style>